package com.sxjh.service.figureReport.impl;

import com.alibaba.fastjson.JSONObject;
import com.sxjh.entity.ComprehensiveReport;
import com.sxjh.entity.param.ComprehensiveReportParam;
import com.sxjh.mapper.ComprehensiveReportMapper;
import com.sxjh.service.figureReport.ComprehensiveReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ComprehensiveReportServiceImpl implements ComprehensiveReportService {

    private Logger logger = LoggerFactory.getLogger(ComprehensiveReportServiceImpl.class);

    @Autowired
    private ComprehensiveReportMapper comprehensiveReportMapper;

    @Override
    public List<JSONObject> queryReportDataByDay(ComprehensiveReportParam param) {
        List<JSONObject> resultJS = new ArrayList<>();
        try{
            JSONObject data = new JSONObject();
            data.put("name","车辆总数量");
            data.put("val",comprehensiveReportMapper.vehiclesTotalNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","车辆超时数量");
            data.put("val",comprehensiveReportMapper.vehiclesOvertimeNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","车辆重新入厂数量");
            data.put("val",comprehensiveReportMapper.vehiclesAgainEnterNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","车辆重新出厂数量");
            data.put("val",comprehensiveReportMapper.vehiclesAgainOutNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","车辆在厂数量");
            data.put("val",comprehensiveReportMapper.vehiclesInNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","车辆出厂数量");
            data.put("val",comprehensiveReportMapper.vehiclesOutNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","制卡超时未入厂数量");
            data.put("val",comprehensiveReportMapper.buildCardOutTimeNum(param));
            resultJS.add(data);

            data = new JSONObject();
            data.put("name","叫号超时数量");
            data.put("val",comprehensiveReportMapper.callTimeoutNum(param));
            resultJS.add(data);
//            resultJS.add(new JSONObject().put("name","车辆重新入厂数量")
//                    .put("val",comprehensiveReportMapper.vehiclesAgainEnterNum(param)));
//            resultJS.add(new JSONObject().put("name","车辆重新出厂数量")
//                    .put("val",comprehensiveReportMapper.vehiclesAgainOutNum(param)));
//            resultJS.add(new JSONObject().put("name","车辆在厂数量")
//                    .put("val",comprehensiveReportMapper.vehiclesInNum(param)));
//            resultJS.add(new JSONObject().put("name","车辆出厂数量")
//                    .put("val",comprehensiveReportMapper.vehiclesOutNum(param)));
//            resultJS.add(new JSONObject().put("name","制卡超时未入厂数量")
//                    .put("val",comprehensiveReportMapper.buildCardOutTimeNum(param)));
//            resultJS.add(new JSONObject().put("name","叫号超时数量")
//                    .put("val",comprehensiveReportMapper.callTimeoutNum(param)));
        }catch (Exception e){
            e.printStackTrace();
        }
        return resultJS;
    }

    @Override
    public List<ComprehensiveReport> queryReportDataByDay2(ComprehensiveReportParam param) {
        return comprehensiveReportMapper.queryReportDataByDay(param);
    }
}
